<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCompanyInviteTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //企业发出人才邀请(函)
        Schema::create('company_invite', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('invite_id');
            $table->integer('company_id')->comment('企业ID');
            $table->integer('user_id')->unsigned()->comment('用户ID');
            $table->integer('need_id')->unsigned()->comment('需求ID');
            $table->integer('resume_id')->unsigned()->comment('简历ID');
            $table->string('job_name')->comment('岗位名称');
            $table->integer('industry')->comment('行业');
            $table->integer('province')->comment('省');
            $table->integer('city')->comment('市');
            $table->integer('area')->comment('区');
            $table->tinyInteger('expect_wages')->default(0)->comment('薪资 0:2k以下；1：2k-5K；2：5k-10k; 3:10k-15k; 4:15k-25k; 5:25k-50k; 6:50k以上 默认0');
            $table->tinyInteger('job_type')->default(0)->comment('职位类型  0 全职 ； 1  兼职 ； 2 实习。 默认0 全职');
            $table->integer('character_exam')->default(0)->comment('性格测试');
            $table->integer('skill_exam')->default(0)->comment('技能测试');
            $table->json('resume')->comment('json数据，用户需求快照');
            $table->tinyInteger('status')->default(0)->comment('状态：0=等待面试确认;1=已确认面试;2=已拒绝面试;3=在线测试未通过;4=面试结束;99=系统作废');
            $table->integer('interview_at')->default(0)->comment('面试时间');
            $table->integer('interview_at_1')->default(0)->comment('可选面试时间1');
            $table->integer('interview_at_2')->default(0)->comment('可选面试时间2');
            $table->integer('interview_at_3')->default(0)->comment('可选面试时间3');
            $table->integer('personal_comment')->default(0)->comment('用户评价，0:未评论');
            $table->integer('company_comment')->default(0)->comment('企业评论，0:未评论');

            $table->tinyInteger('enable_exam')->default(0)->comment('启用试卷，默认：0 即无需考试；1=启用考试');
            $table->integer('exam_id')->default(0)->comment('试卷 对应 exams');
            $table->integer('exam_history_id')->default(0)->comment('考试结果ID，对应 exam_history');

            $table->timestamps();

            $table->foreign('company_id')->references('id')->on('company')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->foreign('user_id')->references('id')->on('users')
                ->onUpdate('cascade')->onDelete('cascade');
            $table->unique(['company_id', 'need_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('company_invite');

    }
}
